package com.排序算法;

import java.util.Random;

public class 冒泡排序 {
    public static void bubbleSort(int arrays[]) {
        for (int i = 0; i < arrays.length - 1; i++) {
            for (int j = i + 1; j < arrays.length; j++) {
                if (arrays[j] < arrays[i]) {
                    int temp = arrays[i];
                    arrays[i] = arrays[j];
                    arrays[j] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int arrays[] = new int[100];
        Random random = new Random();
        for (int i = 0; i < arrays.length; i++) {
            arrays[i] = random.nextInt(1000);
        }
        bubbleSort(arrays);
        System.out.println("冒泡排序算法结果：");
        for (int i = 0; i < arrays.length; i++) {
            if (i % 10 == 0) {
                System.out.println(" ");
            }
            System.out.print(arrays[i] + " ");
        }
    }
}
/**
 * 1 14 34 36 43 58 80 83 95 119
 * 120 131 132 145 147 154 170 171 171 179
 * 191 195 198 202 203 209 220 223 246 271
 * 286 295 305 314 321 321 360 360 398 413
 * 413 422 424 425 440 443 449 463 465 480
 * 482 498 498 523 525 544 549 562 563 568
 * 588 595 596 599 606 609 625 662 676 696
 * 696 737 743 744 748 770 781 784 792 795
 * 815 817 818 842 854 871 873 879 888 906
 * 912 915 931 932 937 948 957 975 977 981
 */